package com.wzh.mall.search.config;

import org.apache.http.HttpHost;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.rest.action.cat.RestHealthAction;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @program: mall
 * @description:
 * @author: Mr.Wang
 * @create: 2021-09-07 15:30
 **/
/*
* 1、导入依赖
* 2、编写配置 给容器中注入一个 RestHighLevelClient
* 3、参照官方的API进行操作
*
* */
@Configuration
public class MallElasticSearchConfig {

    public static final RequestOptions COMMON_OPTIONS;

    static {
        RequestOptions.Builder builder = RequestOptions.DEFAULT.toBuilder();

        COMMON_OPTIONS = builder.build();
    }



    @Bean
    public RestHighLevelClient esRestClient(){
        RestHighLevelClient client=new RestHighLevelClient(
                RestClient.builder(
                        new HttpHost("192.168.44.129",9200,"http")
                )
        );
        return client;
    }


}
